#Region " Imports "

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web.Configuration
Imports System.Net.Configuration
Imports System.Configuration.ConfigurationManager
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports BA.DAL

#End Region

Public Class WebConfigSettings
    Inherits System.Web.UI.UserControl

#Region " Members "


#End Region

#Region " Properties "

    Public ReadOnly Property MainConfiguration() As Configuration
        Get
            Return WebConfigurationManager.OpenWebConfiguration("~")
        End Get
    End Property

    Public ReadOnly Property AppSettingsSection() As AppSettingsSection
        Get
            If IsNothing(MainConfiguration.GetSection("appSettings")) Then
                Throw New ConfigurationErrorsException("The App Settings section is missing from the web config file.  Add a valid App Settings section.")
            Else
                Return CType(MainConfiguration.GetSection("appSettings"), AppSettingsSection)
            End If

        End Get
    End Property

    Public ReadOnly Property ProfileSettingsSection() As System.Web.Configuration.ProfileSection
        Get
            If IsNothing(MainConfiguration.GetSection("system.web/profile")) Then
                Throw New ConfigurationErrorsException("The System.Web Profile section is missing from the web config file.  Add a valid System.Web Profile section.")
            Else
                Return CType(MainConfiguration.GetSection("system.web/profile"), System.Web.Configuration.ProfileSection)
            End If

        End Get
    End Property

    Public ReadOnly Property MailSettingsSection() As MailSettingsSectionGroup
        Get
            If IsNothing(MainConfiguration.GetSectionGroup("system.net/mailSettings")) Then
                Throw New ConfigurationErrorsException("The System.Net MailSettings section is missing from the web config file.  Add a valid System.Net MailSettings section.")
            Else
                Return MainConfiguration.GetSectionGroup("system.net/mailSettings")
            End If

        End Get
    End Property

    Public ReadOnly Property ConnectionString() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.ConnectionStrings("BlazeApps").ToString()) Then
                Throw New ConfigurationErrorsException("The connection string is missing from the web config file.  Add a valid connection string to the connectionStrings section.")
            Else
                Return ConfigurationManager.ConnectionStrings("BlazeApps").ToString().Trim()
            End If
        End Get
    End Property

    Public ReadOnly Property Provider() As DBUtility.Providers
        Get
            If String.IsNullOrEmpty(ConfigurationManager.ConnectionStrings("BlazeApps").ProviderName.ToString) Then
                Return CType(System.Enum.Parse(GetType(DBUtility.Providers), ConfigurationManager.AppSettings("DBProvider").ToString().Trim(), True), DBUtility.Providers)
            Else
                Return CType(System.Enum.Parse(GetType(DBUtility.Providers), ConfigurationManager.ConnectionStrings("BlazeApps").ProviderName.ToString().Trim(), True), DBUtility.Providers)
            End If
        End Get
    End Property

    Public ReadOnly Property ConfigTheme() As String
        Get
            If IsNothing(ConfigurationManager.AppSettings("Theme")) Then
                Return "Default"
            Else
                Return ConfigurationManager.AppSettings("Theme").ToString
            End If
        End Get
    End Property

    Public ReadOnly Property ThumbWidth() As Integer
        Get
            If IsNothing(ConfigurationManager.AppSettings("ThumbWidth")) Then
                Return 150
            Else
                Return CType(ConfigurationManager.AppSettings("ThumbWidth"), Integer)
            End If
        End Get
    End Property

    Public ReadOnly Property ThumbHeight() As Integer
        Get
            If IsNothing(ConfigurationManager.AppSettings("ThumbHeight")) Then
                Return 100
            Else
                Return CType(ConfigurationManager.AppSettings("ThumbHeight"), Integer)
            End If
        End Get
    End Property

    Public ReadOnly Property UseClientEmail() As Boolean
        Get
            If IsNothing(ConfigurationManager.AppSettings("UseClientEmail")) Then
                Return True
            Else
                Return CType(ConfigurationManager.AppSettings("UseClientEmail"), Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property SiteTitle() As String
        Get
            If IsNothing(ConfigurationManager.AppSettings("SiteTitle")) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("SiteTitle").ToString
            End If
        End Get
    End Property

    Protected ReadOnly Property AdminEmail() As String
        Get
            If IsNothing(MailSettingsSection.Smtp.Network.Password) Then
                Return String.Empty
            Else
                Return MailSettingsSection.Smtp.From.ToString.Trim
            End If
        End Get
    End Property

    Protected ReadOnly Property AdminEmailPassword() As String
        Get
            If IsNothing(MailSettingsSection.Smtp.Network.Password) Then
                Return String.Empty
            Else
                Return MailSettingsSection.Smtp.Network.Password.ToString.Trim
            End If
        End Get
    End Property

    Public ReadOnly Property MasterPage() As String
        Get
            If IsNothing(ConfigurationManager.AppSettings("MasterPage")) Then
                Return "~/MasterPages/Main.Master"
            Else
                Return String.Format("~/MasterPages/{0}", ConfigurationManager.AppSettings("MasterPage").ToString().Trim())
            End If
        End Get
    End Property

    Public ReadOnly Property PopUpMasterPage() As String
        Get
            Return "~/MasterPages/PopUp.Master"
        End Get
    End Property

    Public ReadOnly Property MenuOrientation() As Orientation
        Get
            If IsNothing(ConfigurationManager.AppSettings("MenuOrientation")) Then
                Return Orientation.Horizontal
            Else

                If ConfigurationManager.AppSettings("MenuOrientation").ToString().Trim().ToLower() = "horizontal" Then
                    Return Orientation.Horizontal
                End If

                If ConfigurationManager.AppSettings("MenuOrientation").ToString().Trim().ToLower = "vertical" Then
                    Return Orientation.Vertical
                End If

            End If
        End Get
    End Property

    Public ReadOnly Property BannedMessage() As String
        Get
            If IsNothing(ConfigurationManager.AppSettings("BannedMessage")) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("BannedMessage").ToString
            End If
        End Get
    End Property

#Region " RSS Feed Options Section "

    Public ReadOnly Property BlogsFeedTitle() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("BlogsFeedTitle").ToString) Then
                Return String.Empty
            Else
                Return String.Format("{0}, {1}", SiteTitle, ConfigurationManager.AppSettings("BlogsFeedTitle").ToString)
            End If
        End Get
    End Property

    Public ReadOnly Property BlogsFeedDesc() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("BlogsFeedDesc").ToString) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("BlogsFeedDesc").ToString
            End If
        End Get
    End Property

    Public ReadOnly Property EventsFeedTitle() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("EventsFeedTitle").ToString) Then
                Return String.Empty
            Else
                Return String.Format("{0}, {1}", SiteTitle, ConfigurationManager.AppSettings("EventsFeedTitle").ToString)
            End If
        End Get
    End Property

    Public ReadOnly Property EventsFeedDesc() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("EventsFeedDesc").ToString) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("EventsFeedDesc").ToString
            End If
        End Get
    End Property

    Public ReadOnly Property ForumFeedTitle() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("ForumFeedTitle").ToString) Then
                Return String.Empty
            Else
                Return String.Format("{0}, {1}", SiteTitle, ConfigurationManager.AppSettings("ForumFeedTitle").ToString)
            End If
        End Get
    End Property

    Public ReadOnly Property ForumFeedDesc() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("ForumFeedDesc").ToString) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("ForumFeedDesc").ToString
            End If
        End Get
    End Property

    Public ReadOnly Property GalleryFeedTitle() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("GalleryFeedTitle").ToString) Then
                Return String.Empty
            Else
                Return String.Format("{0}, {1}", SiteTitle, ConfigurationManager.AppSettings("GalleryFeedTitle").ToString)
            End If
        End Get
    End Property

    Public ReadOnly Property GalleryFeedDesc() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("GalleryFeedDesc").ToString) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("GalleryFeedDesc").ToString
            End If
        End Get
    End Property

    Public ReadOnly Property NewsFeedTitle() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("NewsFeedTitle").ToString) Then
                Return String.Empty
            Else
                Return String.Format("{0}, {1}", SiteTitle, ConfigurationManager.AppSettings("NewsFeedTitle").ToString)
            End If
        End Get
    End Property

    Public ReadOnly Property NewsFeedDesc() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("NewsFeedDesc").ToString) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("NewsFeedDesc").ToString
            End If
        End Get
    End Property

    Public ReadOnly Property SiteFeedTitle() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("SiteFeedTitle").ToString) Then
                Return String.Empty
            Else
                Return String.Format("{0}, {1}", SiteTitle, ConfigurationManager.AppSettings("SiteFeedTitle").ToString)
            End If
        End Get
    End Property

    Public ReadOnly Property SiteFeedDesc() As String
        Get
            If String.IsNullOrEmpty(ConfigurationManager.AppSettings("SiteFeedDesc").ToString) Then
                Return String.Empty
            Else
                Return ConfigurationManager.AppSettings("SiteFeedDesc").ToString
            End If
        End Get
    End Property

#End Region

#Region " Display Option Section "

    Public ReadOnly Property DisplayUserActivity() As Boolean
        Get
            If IsNothing(AppSettings("DisplayUserActivity")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayUserActivity").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayTags() As Boolean
        Get
            If IsNothing(AppSettings("DisplayTags")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayTags").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayPosts() As Boolean
        Get
            If IsNothing(AppSettings("DisplayPosts")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayPosts").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayBlogs() As Boolean
        Get
            If IsNothing(AppSettings("DisplayBlogs")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayBlogs").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayEvents() As Boolean
        Get
            If IsNothing(AppSettings("DisplayEvents")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayEvents").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayPages() As Boolean
        Get
            If IsNothing(AppSettings("DisplayPages")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayPages").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayPolls() As Boolean
        Get
            If IsNothing(AppSettings("DisplayPolls")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayPolls").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayMostViewedBlogs() As Boolean
        Get
            If IsNothing(AppSettings("DisplayMostViewedBlogs")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayMostViewedBlogs").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayMostCommentsBlogs() As Boolean
        Get
            If IsNothing(AppSettings("DisplayMostCommentsBlogs")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayMostCommentsBlogs").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayHighestRankedBlogs() As Boolean
        Get
            If IsNothing(AppSettings("DisplayHighestRankedBlogs")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayHighestRankedBlogs").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayLatestEvents() As Boolean
        Get
            If IsNothing(AppSettings("DisplayLatestEvents")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayLatestEvents").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayMostViewedEvents() As Boolean
        Get
            If IsNothing(AppSettings("DisplayMostViewedEvents")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayMostViewedEvents").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayMostCommentsEvents() As Boolean
        Get
            If IsNothing(AppSettings("DisplayMostCommentsEvents")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayMostCommentsEvents").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayHighestRankedEvents() As Boolean
        Get
            If IsNothing(AppSettings("DisplayHighestRankedEvents")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayHighestRankedEvents").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayMostViewedPolls() As Boolean
        Get
            If IsNothing(AppSettings("DisplayMostViewedPolls")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayMostViewedPolls").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayMostCommentsPolls() As Boolean
        Get
            If IsNothing(AppSettings("DisplayMostCommentsPolls")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayMostCommentsPolls").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayHighestRankedPolls() As Boolean
        Get
            If IsNothing(AppSettings("DisplayHighestRankedPolls")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayHighestRankedPolls").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplaySlideShow() As Boolean
        Get
            If IsNothing(AppSettings("DisplaySlideShow")) Then
                Return True
            Else
                Return CType(AppSettings("DisplaySlideShow").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property DisplayLinks() As Boolean
        Get
            If IsNothing(AppSettings("DisplayLinks")) Then
                Return True
            Else
                Return CType(AppSettings("DisplayLinks").ToString, Boolean)
            End If
        End Get
	End Property

	Public ReadOnly Property DisplayRecentForumActivity() As Boolean
		Get
			If IsNothing(AppSettings("DisplayRecentForumActivity")) Then
				Return True
			Else
				Return CType(AppSettings("DisplayRecentForumActivity").ToString, Boolean)
			End If
		End Get
	End Property

	Public ReadOnly Property DisplayImageAsTitle() As Boolean
		Get
			If IsNothing(AppSettings("DisplayImageAsTitle")) Then
				Return True
			Else
				Return CType(AppSettings("DisplayImageAsTitle").ToString, Boolean)
			End If
		End Get
	End Property

#End Region

#Region " Enable Option Section "

    Public ReadOnly Property EnableEmailNotifications() As Boolean
        Get
            If IsNothing(AppSettings("EnableEmailNotifications")) Then
                Return True
            Else
                Return CType(AppSettings("EnableEmailNotifications").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableSmilies() As Boolean
        Get
            If IsNothing(AppSettings("EnableSmilies")) Then
                Return True
            Else
                Return CType(AppSettings("EnableSmilies").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableUserGalleries() As Boolean
        Get
            If IsNothing(AppSettings("EnableUserGalleries")) Then
                Return True
            Else
                Return CType(AppSettings("EnableUserGalleries").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableUserBlogs() As Boolean
        Get
            If IsNothing(AppSettings("EnableUserBlogs")) Then
                Return True
            Else
                Return CType(AppSettings("EnableUserBlogs").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableUserEvents() As Boolean
        Get
            If IsNothing(AppSettings("EnableUserEvents")) Then
                Return True
            Else
                Return CType(AppSettings("EnableUserEvents").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableUserPolls() As Boolean
        Get
            If IsNothing(AppSettings("EnableUserPolls")) Then
                Return True
            Else
                Return CType(AppSettings("EnableUserPolls").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableFavorites() As Boolean
        Get
            If IsNothing(AppSettings("EnableFavorites")) Then
                Return True
            Else
                Return CType(AppSettings("EnableFavorites").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableRating() As Boolean
        Get
            If IsNothing(AppSettings("EnableRating")) Then
                Return True
            Else
                Return CType(AppSettings("EnableRating").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableTags() As Boolean
        Get
            If IsNothing(AppSettings("EnableTags")) Then
                Return True
            Else
                Return CType(AppSettings("EnableTags").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableComments() As Boolean
        Get
            If IsNothing(AppSettings("EnableComments")) Then
                Return True
            Else
                Return CType(AppSettings("EnableComments").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableTools() As Boolean
        Get
            If IsNothing(AppSettings("EnableTools")) Then
                Return True
            Else
                Return CType(AppSettings("EnableTools").ToString, Boolean)
            End If
        End Get
    End Property

    Public ReadOnly Property EnableLinkRedirect() As Boolean
        Get
            If IsNothing(AppSettings("EnableLinkRedirect")) Then
                Return False
            Else
                Return CType(AppSettings("EnableLinkRedirect").ToString, Boolean)
            End If
        End Get
    End Property

#End Region

#End Region

End Class
